package impl

import (
	"context"
	"errors"
	"gitee.com/hexug/vblog/tree/master/api/apps/user"
)

// Login 登录
func (i *impl) Login(ctx context.Context, request *user.LoginRequest) (*user.Session, error) {
	//验证下密码是否正确
	if ok := i.Auth.CheckAuth(request); ok {
		//正确就创建session
		s, err := CreatSession(request)
		if err != nil {
			return nil, err
		}
		return s, nil
	}
	return nil, errors.New("用户名或密码不正确")
}

// Logout 登出
func (i *impl) Logout(ctx context.Context, request *user.LogoutRequest) error {
	//删除session
	err := DeleteSession(request)
	return err
}
